﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace InfoMap.DataAccess
{
    public class StateProvider
    {
        private static bool isWebApplication
        {
            get
            {
                return HttpContext.Current != null;                
            }
        }

        public static void Set<T>(string key, T value)
        {
            if (isWebApplication)
            {
                HttpContext.Current.Items.Add(key, value);
            }
            else
                throw new Exception("No support for non web application");
        }

        public static T Get<T>(string key)
        {
            if (isWebApplication)
            {
                return (T)HttpContext.Current.Items[key];
            }
            else
                throw new Exception("No support for non web application");
        }

    }
}
